Skip to content

Add future annotations to prompt_helper for Python 3.9 compat#20850

Open
debu-sinha wants to merge 2 commits intorun-llama:mainfrom
debu-sinha:fix/prompt-helper-py39-compat
Open

Add future annotations to prompt_helper for Python 3.9 compat#20850
debu-sinha wants to merge 2 commits intorun-llama:mainfrom
debu-sinha:fix/prompt-helper-py39-compat

Conversation

@debu-sinha
Copy link
Contributor

prompt_helper.py uses X | Y union syntax (PEP 604) which requires Python 3.10+. On Python 3.9, this raises TypeError: unsupported operand type(s) for |: 'type' and 'type'.

Adding from __future__ import annotations makes the type hints lazy-evaluated strings, which fixes the issue on Python 3.9.

Found this while investigating the CI failure on #20813 where the Python 3.9 test suite was failing on import.

ChatPromptHelper uses PEP 604 union syntax (LLM | None) which
raises TypeError at runtime on Python 3.9. Adding the future
annotations import makes all type hints lazy strings, fixing
the 3.9 test suite.
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant